<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>商品预归类</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'/>
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
</head>
<body>
<div class="content content_frame">
    <h3 class="mainTitle"><img src="${basePath}/images/icon2.png"/>商品预归类</h3>
    </br>
    <ul class="contentNav dib-wrap">
        <li class="dib" id="btnSearch" defaultkey='13'>
            <a><i class='fa fa-search'></i>&nbsp;&nbsp;查&nbsp;询 </a>
        </li>
        <li class="dib ">
            <a onclick="ClearAllInput('SearchTable')">
                <i class='fa fa-refresh'></i>&nbsp;&nbsp;重&nbsp;置 </a>
        </li>
    </ul>
    <br/>
    <table id="SearchTable" width="100%" class="table1">
        <tr>
            <th width="130" class="titleCss130">
                商品HS编码
            </th>
            <td>
                <ui:tsingletableautocomplete
                        keyFieldName="codeTs"
                        valueFieldName="gName"
                        tableName="s_complex"
                        key="CODE_TS"
                        value="G_NAME"/>
                <%--<input type='text'--%>
                       <%--datafield="SearchTable.codeTs"/>--%>
            </td>
            <th width="130" class="titleCss130">
                商品名称
            </th>
            <td>
                <input type='text'
                       datafield="SearchTable.gName"/>
            </td>

        </tr>
    </table>
    <div class="cl"></div>
    <br/>
    <table id="corptable">
    </table>
    <div id="corptablePage">
    </div>
</div>


<script type="text/javascript">
    function showTariff(codeTs) {
        $.post('queryMapTariffInfoList', {hsCode: codeTs}, function (data) {
            if (data != null && data.length > 0) {
                var divHtml = "<div ><table class='table2' style='min-width:100px;width:780px !important;border: 10px;margin: auto;margin-top: 10px;' >";
                for (var i = 0; i < data.length; i++) {
                    if (i == 0) {
                        divHtml += "<tr style='border:none'><td align='right' style='background-color: #f0f0f0' >税号：</td><td>" +
                                data[i].TARIFF_CODE + "</td><td  style='background-color: #f0f0f0' width='12%' align='right'>名称: </td><td colspan='3'>" + data[i].GOODS_NAME + "</td></tr>";
                        divHtml += "<tr style='background-color: #f0f0f0' ><td>最惠国税率</td><td>普通税率</td><td>出口关税率</td><td>增值税率</td><td>出口退税率</td><td>归类公司总计</td></tr>";
                    }
                    divHtml += "<tr><td width='16%'>" + data[i].MFN_RATE + "</td><td width='16%'>" + data[i].COMM_RATE + "</td><td width='16%'>" + data[i].EXPORT_RATE + "</td><td width='16%'>" + data[i].ADD_RATE + "</td><td width='16%'>" + data[i].EXPORT_BACK_RATE + "</td><td width='16%'>" + data[i].CNT + "</td></tr>";
                }
                divHtml += "</table></div>";
                layer.open({
                    type: 1,
                    skin: 'layui-layer-demo', //样式类名
                    closeBtn: 0, //不显示关闭按钮
                    shift: 2,
                    title: '关税信息',
                    area: ['800px', '70%'],
                    shadeClose: true, //开启遮罩关闭
                    content: divHtml
                });
            } else {
                showWarningMsg("暂无关税信息!", "提示");
            }

//            console.log(data);
        });

    }
    $(function () {
        $("#corptable").jqGrid({
            datatype: "json",
            url: "queryHsCodeList",
            colNames: ['id', 'HS编码', '商品名称', '计量单位', '商品描述', '关税信息'],
            colModel: [{name: 'id', index: 'id', key: true, hidden: true}, {
                name: 'codeTs', index: 'codeTs', width: 50
            }, {name: 'gName', index: 'gName'}, {
                name: 'legaluncn', index: 'legaluncn', width: 50
            }, {name: 'criteriondeclare', index: 'criteriondeclare'}, {
                name: 'one', index: 'one', width: 50, formatter: function (cell, indx, rowObj) {
                    return '<a href="javascript:showTariff(' + rowObj.codeTs + ')">查看详情</a>'
                }
            }],
            height: 'auto',
            shrinkToFit: false,
            autoScroll: true,
            rowNum: 10, //每页显示记录数
            rowList: [10, 20, 100], //可调整每页显示的记录数
//            rownumbers: true,
            multiselect: true, //是否支持多选
            multiselectWidth: 35,
            viewrecords: true, //是否显示行数
            pager: "#corptablePage", //分页工具栏
            altRows: true,
            altclass: 'someClass',
            sortable: true,
            sortname: 'applytime',
            sortorder: 'asc',
            width: $('body').width(),
            loadComplete: function () {
                var rowNum = $(this).jqGrid('getGridParam', 'records');
                if (rowNum <= 0) {
                    if ($(this).parent().children('.norecords').length == 0)
                        $(this).parent().append("<div class=\"norecords\">暂无数据！</div>");
                    $(this).parent().children('.norecords').show();
                } else {//如果存在记录，则隐藏提示信息。
                    $(this).parent().children('.norecords').hide();
                }
                $("#" + this.id).setGridWidth($(window).width() * 0.98);
                $(".ui-jqgrid tr.ui-row-ltr td").css('text-align', 'center');
            }
        });

        //查询
        $("#btnSearch").click(function () {
            var jsonStr = customFormToData("SearchTable");
            $("#corptable").jqGrid('setGridParam', {
                url: "queryHsCodeList", postData: JSON.parse(jsonStr), page: 1
            }).trigger("reloadGrid"); //重新载入
        });
    });


</script>
</body>
</html>
